package xyz.chenyongpeng.userconsumerdubbo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import xyz.chenyongpeng.entity.ZsSystem;
import xyz.chenyongpeng.service.IZsSystemService;
import xyz.chenyongpeng.utils.ServiceTel;

import java.util.ArrayList;
import java.util.List;

@Service
public class SystemService {

    @Autowired
    private IZsSystemService zsSystemService;

    public List<ServiceTel> getServiceTel(){
        List<ZsSystem> list = zsSystemService.list(null);
        List<ServiceTel> data = new ArrayList<>();
        for (ZsSystem obj:list) {
            String text1 = obj.getServiceTelText1();
            String text2 = obj.getServiceTelText2();

            String tel1 = obj.getServiceTel1();
            String tel2 = obj.getServiceTel2();


            if (!StringUtils.isEmpty(text1) && !StringUtils.isEmpty(tel1)){
                ServiceTel serviceTel = new ServiceTel(text1, tel1);
                data.add(serviceTel);
            }
            if (!StringUtils.isEmpty(text2) && !StringUtils.isEmpty(tel2)){
                ServiceTel serviceTel = new ServiceTel(text2, tel2);
                data.add(serviceTel);
            }
        }
        return data;
    }
}
